package helperClasses;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Vector;

public class ClassInfo implements Serializable, Comparator<Object>{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8768449076091068084L;
	private String name, major;
	
	public ClassInfo() {
		
	}

	public ClassInfo(String name, String major) {
		super();
		this.name = name;
		this.major = major;
	}
	
	public ClassInfo(ClassInfo cla) {
		this.name = cla.name;
		this.major = cla.major;
	}
	
	public ClassInfo clone() {
		return new ClassInfo(this);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ClassInfo other = (ClassInfo) obj;
		if (major == null) {
			if (other.major != null)
				return false;
		} else if (!major.equals(other.major))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	public String getMajor() {
		return major;
	}

	public String getName() {
		return name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((major == null) ? 0 : major.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	public void setMajor(String major) {
		this.major = major;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String toString() {
		String s = "Name: " + this.name;
		return s;
		
	}
	
	public Vector<Object> toVector() {
		Vector<Object> vec = new Vector<Object>();
		
		vec.add(this.name);
		vec.add(this.major);
		
		return vec;
	}

	@Override
	public int compare(Object o1, Object o2) {
		ClassInfo h1 = (ClassInfo)o1;
		ClassInfo h2 = (ClassInfo)o2;
		
		return h1.toString().compareTo(h2.toString());
	}
}
